Loading TOC...

MarkLogic 9 Product Documentation
GET /v1/alert/rules/{name}

Summary

Retrieve the alerting rule definition installed with the given name.

URL Parameters
database? Perform this operation on the named content database instead of the default content database associated with the REST API instance. Using an alternative database requires the "eval-in" privilege; for details, see Security Requirements in the REST Application Developer's Guide.
format? The expected content type of the results. This is equivalent to specifying the format in the Accept header. The format parameter overrides the Accept header if both are present. Accepted value: xml and json. Default: xml.
Request Headers
Accept* The expected MIME type of the information in the response. Accepted types: application/json or application/xml. Ignored if the request includes a format parameter value.
Response Headers
Content-type The MIME type of the data in the response, either application/json or application/xml, depending upon the MIME type requested through the format parameter or Accept header on the request.

Response

On success, MarkLogic Server responds with a 200 status and the requested rule definition in the response body. Results are returned as either XML or JSON, depending up on the format request parameter or the Accept header setting.

If no rule matching {name} is installed, MarkLogic Server returns status code 404.

If the Alerting API is not enabled, MarkLogic Server returns status 403.

Required Privileges

This operation requires the rest-reader role, or the following privilege:

http://marklogic.com/xdmp/privileges/rest-reader

Usage Notes

The expected response type can be specified using either the format parameter or Accept header. One or the other must be supplied. If both are supplied and are different, the format parameter takes precedence.

For more information on the alerting features of the REST API, see Alerting in the REST Application Developer's Guide.

Example

$ curl --anyauth --user user:password -X GET -i -H "Accept: application/xml" \
    http://localhost:8000/v1/alert/rules/example

==> The definition of the rule installed under the name "example", in XML.
    MarkLogic Server responds with output similar to the following:

HTTP/1.1 200 OK
Content-type: application/xml; charset=utf-8
Server: MarkLogic
Content-Length: 499
Connection: Keep-Alive
Keep-Alive: timeout=5

<rapi:rule xmlns:rapi="http://marklogic.com/rest-api">
  <rapi:name>example</rapi:name>
  <rapi:description>An example rule.</rapi:description>
  <search:search xmlns:search="http://marklogic.com/appservices/search">
    <search:qtext>xdmp</search:qtext>
    <search:options>
      <search:term>
        <search:term-option>case-sensitive</search:term-option>
      </search:term>
    </search:options>
  </search:search>
  <rapi:rule-metadata>
    <author>me</author>
  </rapi:rule-metadata>
</rapi:rule>
  

Example

$ curl --anyauth --user user:password -X GET -i -H "Accept: application/json" \
    http://localhost:8000/v1/alert/rules/example

==> The definition of the rule installed under the name "example", in JSON.
    MarkLogic Server responds with output similar to the following:

HTTP/1.1 200 OK
Content-type: application/json; charset=utf-8
Server: MarkLogic
Content-Length: 178
Connection: Keep-Alive
Keep-Alive: timeout=5

{ "rule": {
    "name": "example",
    "description": "An example rule.",
    "search": {
      "qtext": [ "xdmp" ],
      "options": {
        "term": { "term-option": [ "case-sensitive" ] }
      }
    },
    "rule-metadata": { "author": "me" }
} }
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.